export default {
	template: '',
	data: function() {
		return {
			reqParam:'',/* reqParam:父组件参数（保留属性名） */
			
			mainUnit:'emptyComponent',
			username:'',password: '',
			loginCode:'',
			loginCodeUrl: Config.baseURL + '/view/json/loginCode.png',
			codeUrl: Config.baseURL + '/view/json/loginCode.png',
			submitBtn:{
				text:'登录',loadingTips:'',disabled:false,style:null
			},
			shakeActive:false,
			reqParas:'abf',user:{}
		}
	},
	methods: {
		/* 父组件回调（保留函数名） */
		parentCallback(param){},
		//登录提交
		formSubmit(){
			console.log('form submiting',this);
			var this_ = this
			Request.formSubmit({
				vueObj:this,
				formRefName:'loginForm',
				loadType:1,//load类型，0遮罩loading，1按钮loading(需要element元素不为空)，其它值不显示loading
				element:this.submitBtn,//显示loading动画的按钮 vue实例对象；按钮需要绑定v-bind:disabled和v-bind:style属性
				loadingContent:'loadingTips',//显示loading动画内容的data变量名
				callback:function(res){
					console.log('res.data.code',res.data.code);
					if(res.data.code == 1){
						this_.submitBtn.text = '登录成功，正在进入系统';
						location.href = Config.baseURL + '/main';
					}else{
						//登录错误提示
					}
				}
			});
		},
		//自动获取验证码
		getLoginCode(){
			var this_ = this;
			Request.get({
				url:'/view/json/loginCode.json',
				callback:function(res){
					if(!!res.data){
						this_.loginCode = res.data.data;
					}
				}
			});
		},
		//更换验证码
		changeLoginCode(){
			this.loginCodeUrl = this.codeUrl + '?' + new Date().getTime();
		},
		//子组件测试
		req(){
			var this_ = this;
			//动态创建组件并挂载
			ComponentUtil.build({
				url : '/view/test',
				reqParam : {name:'这是给子组件的参数'},
				parentInst: this_ ,
				componentSlot : 'mainUnit'
			});
		},
		req2(){
			var this_ = this;
			//动态创建组件并挂载
			ComponentUtil.build({
				url : '/view/test2',
				reqParam : {name:'这是给子组件的参数',remark:'收到请回复'},
				parentInst: this_ ,
				componentSlot : 'mainUnit',
				parentCallback:function(res){
					console.log('子组件的回复',res);
					alert('子组件的回复的内容==>' + res);
				}
			});
		},
		parentFun(paras){
			alert('this is parent, sun paras is ' + paras);
		},
		enter(paras){
			
			ComponentUtil.build({
				url : '/view/main',
				reqParam : {},
				parentInst: eval(Config.vueAppVmName) ,
				componentSlot : 'main',
				pushState: true
			});
			
		}

	}
}